package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.dto.ShopCarUpdateDto;
import com.briup.estore.common.utils.JsonUtils;
import com.briup.estore.service.ShopCarService;
import com.briup.estore.service.impl.ShopCarServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/4 下午4:48
 * @Description 修改购物车中商品数量
 **/
@WebServlet("/shopCar/update")
public class ShopCarUpdateServlet extends  BaseServlet {
    private ShopCarService shopCarService=new ShopCarServiceImpl();

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String data = readData(req);
        ShopCarUpdateDto dto = JsonUtils.toObject(data, ShopCarUpdateDto.class);
        shopCarService.updateNum(dto);
        writeData(resp, Result.success());
    }
}
